package router

import (
	"web-service-gin/src/app/config"
	"web-service-gin/src/pkg/aop"

	"github.com/gin-contrib/pprof"
	"github.com/gin-gonic/gin"
)

func New() *gin.Engine {
	gin.SetMode(config.C.RunMode)
	r := gin.New()
	r.Use(aop.Cors(), aop.Logger(), aop.Recovery())
	configRouter(r)
	return r
}

func configRouter(r *gin.Engine) {
	if config.C.PProf {
		pprof.Register(r, "/api/debug/pprof")

	}

	test := r.Group("/test")
	{
		test.GET("/list", TestView)
	}
}
